package com.faxsun.core.web.security;

/**
 * 风控相关的常量
 * 
 * @author zhaoteng.song@faxsun.com
 *
 */
public class FraudConstants {

	/**
	 * 当前session是否需要验证码验证的属性名称
	 */
	public static final String IS_CAPTCHA_REQUIRED = "isCaptchaRequired";
	
	public static final String CAPTCH_TYPE="captchaType";
	
	public static final String FRAUD_LEVEL_PROPERTY="fraud.level";

	/**
	 * 风控激活等级
	 * 
	 * @author zhaoteng.song@faxsun.com
	 *
	 */
	public enum FraudEnableLevel {
		/**
		 * 禁用
		 */
		DISABLE(0),
		/**
		 * 激活但不执行风控策略
		 */
		ENABLE(1),
		/**
		 * 激活且执行风控策略
		 */
		VALIDATE(2);

		FraudEnableLevel(int level) {
			this.level = level;
		}

		int level;

		/**
		 * 风控等级对应的整数值
		 * @return 风控等级
		 */
		public int getValue() {
			return this.level;
		}

		public static FraudEnableLevel parseInt(int level) {
			FraudEnableLevel[] levels = FraudEnableLevel.values();
			for (FraudEnableLevel l : levels) {
				if (l.getValue() == level) {
					return l;
				}
			}

			return DISABLE;
		}
	}
}
